# Maintainer: Dominic Sisneros <dsisnero@gmail.com>

_realname=lasem
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.4
pkgrel=1
pkgdesc="Lasem aims to be a C/Gobject based SVG/Mathml renderer (mingw-w64)"
arch=('any')
url="https://github.com/GNOME/lasem"
license=('LGPL')
license=('GPL' 'MPL' 'LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
             "${MINGW_PACKAGE_PREFIX}-glib2"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-cairo"
             "${MINGW_PACKAGE_PREFIX}-pango"
             "${MINGW_PACKAGE_PREFIX}-libxml2"
             "flex"
             "bison"
             "intltool"
            )
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/GNOME/lasem/archive/LASEM_${pkgver//./_}.tar.gz"
        001-fix-doc-install.patch
        002-no-undefined.patch)
sha256sums=('d23779ab5626872f96fba9400d6062027aecadc60b76cf18ff4320e0d63118cf'
            '9c9321e4f2c841d3b348204519b5e508492521f4c2c512ecfb8a083a06dca1e3'
            '7f98e6d191c53ffe80235258c5114c78e3e7af889c5c07c79ed4134e2be7e3b8')

prepare() {
  cd "${_realname}-LASEM_${pkgver//./_}"
  patch -p1 -i ${srcdir}/001-fix-doc-install.patch
  patch -p1 -i ${srcdir}/002-no-undefined.patch
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}

  ../${_realname}-LASEM_${pkgver//./_}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --sysconfdir=${MINGW_PREFIX}/etc \
    --enable-gtk-doc

  make
}

# check() {
#  #   make check
# }

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" -j1 install

  install -Dm644 ${srcdir}/${_realname}-LASEM_${pkgver//./_}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
